package com.heyige.dto;

import java.time.LocalDateTime;
import java.util.List;

import com.heyige.entity.SensitiveWord;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

@Data
public class SensitiveWordDto {
    
    public static class CheckResult {
        private String originalText;
        private String processedText;
        private Boolean hasSensitiveWord = false;
        private Boolean isRejected = false;
        private String rejectReason;
        private List<MatchedWord> matchedWords;
        
        // Getters and Setters
        public String getOriginalText() {
            return originalText;
        }
        
        public void setOriginalText(String originalText) {
            this.originalText = originalText;
        }
        
        public String getProcessedText() {
            return processedText;
        }
        
        public void setProcessedText(String processedText) {
            this.processedText = processedText;
        }
        
        public Boolean getHasSensitiveWord() {
            return hasSensitiveWord;
        }
        
        public void setHasSensitiveWord(Boolean hasSensitiveWord) {
            this.hasSensitiveWord = hasSensitiveWord;
        }
        
        public Boolean getIsRejected() {
            return isRejected;
        }
        
        public void setIsRejected(Boolean isRejected) {
            this.isRejected = isRejected;
        }
        
        public String getRejectReason() {
            return rejectReason;
        }
        
        public void setRejectReason(String rejectReason) {
            this.rejectReason = rejectReason;
        }
        
        public List<MatchedWord> getMatchedWords() {
            return matchedWords;
        }
        
        public void setMatchedWords(List<MatchedWord> matchedWords) {
            this.matchedWords = matchedWords;
        }
    }
    
    public static class MatchedWord {
        private String word;
        private String category;
        private Integer level;
        private SensitiveWord.Action action;
        
        // Getters and Setters
        public String getWord() {
            return word;
        }
        
        public void setWord(String word) {
            this.word = word;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public Integer getLevel() {
            return level;
        }
        
        public void setLevel(Integer level) {
            this.level = level;
        }
        
        public SensitiveWord.Action getAction() {
            return action;
        }
        
        public void setAction(SensitiveWord.Action action) {
            this.action = action;
        }
    }
    
    public static class AddRequest {
        @NotBlank(message = "敏感词不能为空")
        @Size(max = 100, message = "敏感词长度不能超过100")
        private String word;
        
        @Size(max = 50, message = "分类长度不能超过50")
        private String category = "默认";
        
        @NotNull(message = "级别不能为空")
        private Integer level = 1;
        
        @NotNull(message = "处理方式不能为空")
        private SensitiveWord.Action action = SensitiveWord.Action.REPLACE;
        
        @Size(max = 100, message = "替换文本长度不能超过100")
        private String replacement = "***";
        
        // Getters and Setters
        public String getWord() {
            return word;
        }
        
        public void setWord(String word) {
            this.word = word;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public Integer getLevel() {
            return level;
        }
        
        public void setLevel(Integer level) {
            this.level = level;
        }
        
        public SensitiveWord.Action getAction() {
            return action;
        }
        
        public void setAction(SensitiveWord.Action action) {
            this.action = action;
        }
        
        public String getReplacement() {
            return replacement;
        }
        
        public void setReplacement(String replacement) {
            this.replacement = replacement;
        }
    }
    
    public static class UpdateRequest {
        @NotBlank(message = "敏感词不能为空")
        @Size(max = 100, message = "敏感词长度不能超过100")
        private String word;
        
        @Size(max = 50, message = "分类长度不能超过50")
        private String category;
        
        private Integer level;
        
        private SensitiveWord.Action action;
        
        @Size(max = 100, message = "替换文本长度不能超过100")
        private String replacement;
        
        // Getters and Setters
        public String getWord() {
            return word;
        }
        
        public void setWord(String word) {
            this.word = word;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public Integer getLevel() {
            return level;
        }
        
        public void setLevel(Integer level) {
            this.level = level;
        }
        
        public SensitiveWord.Action getAction() {
            return action;
        }
        
        public void setAction(SensitiveWord.Action action) {
            this.action = action;
        }
        
        public String getReplacement() {
            return replacement;
        }
        
        public void setReplacement(String replacement) {
            this.replacement = replacement;
        }
    }
    
    public static class ImportRequest {
        @NotNull(message = "敏感词列表不能为空")
        private List<String> words;
        
        @Size(max = 50, message = "分类长度不能超过50")
        private String category = "默认";
        
        private Integer level = 1;
        
        private SensitiveWord.Action action = SensitiveWord.Action.REPLACE;
        
        @Size(max = 100, message = "替换文本长度不能超过100")
        private String replacement = "***";
        
        // Getters and Setters
        public List<String> getWords() {
            return words;
        }
        
        public void setWords(List<String> words) {
            this.words = words;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public Integer getLevel() {
            return level;
        }
        
        public void setLevel(Integer level) {
            this.level = level;
        }
        
        public SensitiveWord.Action getAction() {
            return action;
        }
        
        public void setAction(SensitiveWord.Action action) {
            this.action = action;
        }
        
        public String getReplacement() {
            return replacement;
        }
        
        public void setReplacement(String replacement) {
            this.replacement = replacement;
        }
    }
    
    public static class ImportResult {
        private Integer totalCount = 0;
        private Integer successCount = 0;
        private Integer failureCount = 0;
        private List<String> failureReasons;
        
        // Getters and Setters
        public Integer getTotalCount() {
            return totalCount;
        }
        
        public void setTotalCount(Integer totalCount) {
            this.totalCount = totalCount;
        }
        
        public Integer getSuccessCount() {
            return successCount;
        }
        
        public void setSuccessCount(Integer successCount) {
            this.successCount = successCount;
        }
        
        public Integer getFailureCount() {
            return failureCount;
        }
        
        public void setFailureCount(Integer failureCount) {
            this.failureCount = failureCount;
        }
        
        public List<String> getFailureReasons() {
            return failureReasons;
        }
        
        public void setFailureReasons(List<String> failureReasons) {
            this.failureReasons = failureReasons;
        }
    }
    
    public static class SensitiveWordResponse {
        private Long id;
        private String word;
        private String category;
        private Integer level;
        private SensitiveWord.Action action;
        private String replacement;
        private Boolean isActive;
        private LocalDateTime createdAt;
        private LocalDateTime updatedAt;
        
        // Getters and Setters
        public Long getId() {
            return id;
        }
        
        public void setId(Long id) {
            this.id = id;
        }
        
        public String getWord() {
            return word;
        }
        
        public void setWord(String word) {
            this.word = word;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public Integer getLevel() {
            return level;
        }
        
        public void setLevel(Integer level) {
            this.level = level;
        }
        
        public SensitiveWord.Action getAction() {
            return action;
        }
        
        public void setAction(SensitiveWord.Action action) {
            this.action = action;
        }
        
        public String getReplacement() {
            return replacement;
        }
        
        public void setReplacement(String replacement) {
            this.replacement = replacement;
        }
        
        public Boolean getIsActive() {
            return isActive;
        }
        
        public void setIsActive(Boolean isActive) {
            this.isActive = isActive;
        }
        
        public LocalDateTime getCreatedAt() {
            return createdAt;
        }
        
        public void setCreatedAt(LocalDateTime createdAt) {
            this.createdAt = createdAt;
        }
        
        public LocalDateTime getUpdatedAt() {
            return updatedAt;
        }
        
        public void setUpdatedAt(LocalDateTime updatedAt) {
            this.updatedAt = updatedAt;
        }
    }
}